package com.aabte.springcloudlearn.feigncustomerdemo.service;

import com.aabte.springcloudlearn.common.beans.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 服务提供者的Feign
 * {@link FeignClient}注解的value属性对应服务提供者的实例名称
 *
 * @author Daniel
 */
@FeignClient(value = "hello-service/user")
public interface UserCustomerFeignService {

    @RequestMapping
    List<User> queryAllUser();

    @RequestMapping(value = "/{id}")
    User queryUserById(@PathVariable(value = "id") Long userId);

    @RequestMapping
    List<User> queryUsers(@RequestParam(value = "ids") List<Long> ids);

    @RequestMapping(value = "/header")
    List<User> queryUsersByRegion(@RequestHeader(value = "region") String region);

    @RequestMapping(method = RequestMethod.POST)
    User addUser(@RequestBody User user);

    @RequestMapping(method = RequestMethod.PUT)
    User updateUser(@RequestBody User user);

    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    User deleteUser(@PathVariable(value = "id") Long id);
}
